{% extends "blogs/base.html" %}

{% load humanize %}

{% block extratitle %} &raquo Search Results{% endblock %}

{% block blogcontent %}
    <h2>Search Results</h2>
    <div id="search-again">
        <form id="blogSearch" method="GET" action="{% url blogs.main.search blog_slug %}">
            <input type="text" class="text" name="query" id="query" value="{{ query }}"/>
            <input type="submit" value="Search"/>
        </form>
    </div>
    
    {% if posts %}
    	<p class="meta">Showing {{ start }}-{{ end }} of {{ total|intcomma }} hits.
        <ol class="results" start="{{ start }}">
        {% for post in posts %}
            <li class="result {% if forloop.last %}last{% endif %}">
                <h4>
                    <a href="{{ post.get_absolute_url }}">{{ post.title }}</a>
                </h4>
                <p class="summary">{{ post.body|truncatewords_html:50|striptags }}</p>
                <p class="datetime">{{ post.pub_date|naturalday:date_format }} at {{ post.pub_date|date:time_format }}</p>
            </li>
        {% endfor %}
        </ol>
        <p id="search-nav">
            {% if has_next_page %}<a href="{% url blogs.main.page blog_slug,next_page %}">&laquo; Older posts</a>{% endif %}
            {% if has_previous_page %}{% if has_next_page %}| {% endif %}<a href="{% url blogs.main.page blog_slug,prev_page %}">Newer posts &raquo;</a>{% endif %}
        </p>
    {% else %}
        <p id="no-results">No results found for your query. Please try another.</p>
    {% endif %}
{% endblock %}
